/**   
 * @Title: BeiDanBuyCommunicater.java 
 * @Package com.esun.rabbit2.communicaters.beijingdanchang
 * @Description: 北单复式代购接口 
 * @author: Kael gaojian@500wan.com
 * @date: 2012-4-5 上午11:39:40 
 * Copyright: (C) 2011 Shenzhen E-sun Sky Net Technology Co.,ltd.
 */
package com.esun.rabbit2.communicaters.beijingdanchang;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;

import javax.xml.parsers.ParserConfigurationException;

import org.apache.http.client.ClientProtocolException;
import org.xml.sax.SAXException;
import com.esun.config.BussinessCode;
import com.esun.config.Config;
import com.esun.config.DistributionChannels;
import com.esun.config.Key;
import com.esun.config.Language;
import com.esun.model.UserInfo;
import com.esun.network.ServerCommunicater;
import com.esun.util.HashMapUtil;
/**
 * @ClassName: BeiDanBuyCommunicater
 * @Description: 北单购买（包括复式代购及发起合买）接口
 * @author: Kael gaojian@500wan.com
 * @date: 2012-4-5 上午11:39:40
 * 
 */
public class BeiDanBuyCommunicater extends ServerCommunicater{
	private boolean isSucceed = false;
	public boolean isBuySucceed(int beishu, long allMoney, int guoguanType, 
			String codes, String danma, String sgtype, String sgtypename, int ishm, String expect, 
			String anumber, String buynumber, int isbaodi, String baodinumber, String ratio, String version)
					throws ClientProtocolException, IOException, ParserConfigurationException,
			SAXException{
		ArrayList<HashMap<String, String>> arraylist = new ArrayList<HashMap<String, String>>();
		arraylist.add(HashMapUtil.getMapItem(BussinessCode.PASER_MID, BussinessCode.MID_BEIDAN_NORMALBUY));
		arraylist.add(HashMapUtil.getMapItem(BussinessCode.PASER_CK, UserInfo.getUserInfo().getUserSession()));//CK
		arraylist.add(HashMapUtil.getMapItem(Key.KEY_CHANNEL, DistributionChannels.QUDAO));//渠道号
		arraylist.add(HashMapUtil.getMapItem(Key.KEY_LOTID, Config.BEIJINGZUQIUDANCHANG));//彩种：北京足球单场
		arraylist.add(HashMapUtil.getMapItem(Key.KEY_PLAYID, Config.PLAYID_BEIJINGZUQIUDANCHANG_SHENGPINGFU));//彩票玩法编号
		arraylist.add(HashMapUtil.getMapItem(Key.KEY_FAMONEY, Long.toString(allMoney)));//用户总金额
		arraylist.add(HashMapUtil.getMapItem(Key.KEY_SGTYPE, sgtype));//过关方式
		arraylist.add(HashMapUtil.getMapItem(Key.KEY_SGTYPENAME, sgtypename));//过关方式字符串（如3串1,5串1）
		arraylist.add(HashMapUtil.getMapItem(Key.KEY_BEISHU, Integer.toString(beishu)));//倍数
		arraylist.add(HashMapUtil.getMapItem(Key.KEY_CODES, codes));//投注内容
		arraylist.add(HashMapUtil.getMapItem(Key.KEY_DANMA, danma));//胆码
		arraylist.add(HashMapUtil.getMapItem(Key.KEY_ISHM, Integer.toString(ishm)));//是否合买
		arraylist.add(HashMapUtil.getMapItem(Key.KEY_EXPECT, expect));//期号
		arraylist.add(HashMapUtil.getMapItem(Key.KEY_TITLE, Language.STR_FUSHI_TITLE));//标题
		arraylist.add(HashMapUtil.getMapItem(Key.KEY_CONTENT, "内容"));//内容
		arraylist.add(HashMapUtil.getMapItem(Key.KEY_ANUMBER, anumber));//总份数
		arraylist.add(HashMapUtil.getMapItem(Key.KEY_BUYNUMBER, buynumber));//购买的份数
		arraylist.add(HashMapUtil.getMapItem(Key.KEY_ISBAODI, Integer.toString(isbaodi)));//是否保底
		arraylist.add(HashMapUtil.getMapItem(Key.KEY_BAODINUMBER, baodinumber));//保底金额
		arraylist.add(HashMapUtil.getMapItem(Key.KEY_RATIO, ratio));//提成
		arraylist.add(HashMapUtil.getMapItem(Key.KEY_VERSION,version));//版本号
		// 过关类型       3 自由过关 2 多串过关
		if (guoguanType == 3) {
			arraylist.add(HashMapUtil.getMapItem(Key.KEY_GGGROUP, Config.STR_ZIYOU_GUOGUAN));
		} else if (guoguanType == 2) {
			arraylist.add(HashMapUtil.getMapItem(Key.KEY_GGGROUP, Config.STR_DUOCHUAN_GUOGUAN));
		} 
		
//		arraylist.add(HashMapUtil.getMapItem(Key.KEY_ZHUSHU, Integer.toString(zhushu)));//注数
		//写入服务器信息
		super.getServerResponse(arraylist, true);
		if (super.getState() == 100) {// 通信成功返回100
			isSucceed = true;
		}else{
			isSucceed = false;
		}
		return isSucceed;
	}
	
}
